<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>
  <div id="div1"></div>
  <script>
    var obj1 = { name: 'obj1' }
    var arr = [1, 2, 3, 4, 5]
    for (var i = 0; i < arr.length; i++) {
      console.log(arr[i]);
    }

    arr.forEach(function (item) {
      console.log(item);
      console.log(this);
    }, obj1)

    var arr2 = arr.map(function (item) {
      if (item > 2) {
        return true
      }
      // return item+1
    })
    console.log(arr2);

    var arr3 = arr.filter(function (item) {
      return item > 2
      // return item+1
    })
    console.log(arr3);

    console.log(arr);
    var res = arr.some(function (item) {
      if (item > 10) { return true }
    })
    console.log(res);


    var date = new Date();
    document.getElementById('app').innerHTML = date

    console.log(date.getFullYear());


    document.getElementById('div1').innerHTML = obj1


    console.log(Math.floor(Math.random() * 100) + 1); // [0 - 100) =>  [0-99] => [1-100]


    console.log('1234'.split('2'));

    var age = prompt("请输入你的年龄:", "18");
    if (age < 14)
      console.log("你是儿童");
    else if (age < 24)
      console.log("你是青少年");
    else if (age < 40)
      console.log("你是青年人");
    else if (age < 60)
      console.log("你是中年人");
    else
      console.log("你是老年人");

    if (a > 1) {
      b = 1
    } else {
      b = 2
    }

    b = a > 1 ? 1 : 2
  </script>
</body>

</html>